Skip to content

Conversation

siverne
Copy link
Member

@siverne siverne commented Nov 10, 2026

Closes #33. Depends on #39 (migrations), so merge that first.

  • Migration: review table with die roll 1–6, optional comment (max 500 characters) and one review per user per wine.
  • GraphQL: saveReview and deleteReview mutations, recentReviews and myReview queries, and studentRating and reviews on Wine.
  • Input is validated before it reaches the database, and invalid input gives BAD_USER_INPUT with a readable message.
  • Users are identified by an anonymous UUID from the browser until we have login (Account system #29). The ID is never returned by the API.
  • docs/api.md explains how the frontend uses it.

Tested locally: saving, updating, deleting, recent reviews and invalid input. 35 backend tests pass, typecheck passes.

After merging: run npm ci and npm run db:migrate in backend/ on the VM, then restart the backend.

@siverne siverne requested a review from a team as a code owner November 10, 2026 18:40
Copy link
Member

@williasc williasc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. studentRating and reviews each run their own query for every wine. A 50-wine page that asks for both makes about 100 extra queries that are unnecessary.
  2. Review.wine: it also runs one query per review. It can crash, because it calls toWine(rows[0]) without checking that the wine was found.
  3. authorName can only produce 9000 different names. The chance of overlapping names is very high on a large dataset. Student #4821 is fine, but should be deterministic at least to support 9k students at the minimum

@siverne
Copy link
Member Author

siverne commented Nov 11, 2026

Thanks, all three are fixed:

studentRating and reviews now use DataLoader, so a page of wines runs one query per field instead of one per wine.

Review.wine also uses DataLoader, and gives a clear error instead of crashing if the wine is missing.

Students are now stored in their own table with a unique number, so the names are “Student #1”, “Student #2” and so on, with no limit and no collisions.

The review migration is changed, since it is not merged yet. If you ran it locally, run npm run db:migrate:down before pulling and npm run db:migrate after.

@siverne siverne requested a review from williasc November 11, 2026 12:24
@siverne siverne dismissed williasc’s stale review November 11, 2026 13:59

The merge-base changed after approval.

williasc
williasc previously approved these changes Nov 11, 2026
Copy link
Member

@williasc williasc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Approved to merge with main.

Copy link
Member

@williasc williasc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Re-approving.

williasc
williasc previously approved these changes Nov 11, 2026
Copy link
Member

@williasc williasc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.

@williasc williasc closed this Nov 11, 2026
@williasc williasc reopened this Nov 11, 2026
@williasc williasc dismissed their stale review November 11, 2026 14:03

The merge-base changed after approval.

Copy link
Member

@williasc williasc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to approve again

@williasc williasc merged commit bf7bb72 into main Nov 11, 2026
@williasc williasc deleted the 33-reviews branch November 11, 2026 14:04
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reviews (vinanmeldelser)
2 participants